package noppes.vc.containers;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import noppes.vc.Server;
import noppes.vc.constants.PacketClient;

public class ContainerTradingBlock$SlotTrader extends Slot {
   // $FF: synthetic field
   final ContainerTradingBlock this$0;

   public ContainerTradingBlock$SlotTrader(ContainerTradingBlock this$0, IInventory par1iInventory, int par2, int par3, int par4) {
      super(par1iInventory, par2, par3, par4);
      this.this$0 = this$0;
   }

   public boolean isItemValid(ItemStack par1ItemStack) {
      if (ContainerTradingBlock.access$000(this.this$0).world.isRemote) {
         return this.this$0.tile.trader1 != null && this.this$0.tile.trader2 != null && this.this$0.state < 3;
      } else {
         return this.this$0.tile.isFull() && this.this$0.state < 3;
      }
   }

   public void onSlotChanged() {
      super.onSlotChanged();
      if (!ContainerTradingBlock.access$000(this.this$0).world.isRemote && this.this$0.tile.isFull()) {
         EntityPlayer other = this.this$0.tile.other(ContainerTradingBlock.access$000(this.this$0));
         if (other != null) {
            if (this.this$0.state == 2 || this.this$0.state == 1) {
               this.this$0.setState(0);
               ((ContainerTradingBlock)other.openContainer).setState(0);
            }

            Server.sendData((EntityPlayerMP)other, PacketClient.GUI_DATA, this.this$0.itemsToComp());
         }
      }
   }
}
